﻿using Furion.DatabaseAccessor;
using System.Threading;
using System.Threading.Tasks;
using YFurion.Locators;

namespace YFurion.Application
{
    /// <summary>
    /// 方法包括：CURD、获取全部、分页获取 
    /// </summary>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TGetAllInput"></typeparam>
    public interface IEFCoreApplicationService<TEntityDto, TKey, in TGetAllInput> : IEFCoreApplicationService<TEntityDto, TKey, TGetAllInput, TEntityDto>
        where TEntityDto : class, IEntityDto<TKey>
    {
    }

    /// <summary>
    /// 方法包括：CURD、获取全部、分页获取 
    /// </summary>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TGetAllInput"></typeparam>
    /// <typeparam name="TCreateInputDto"></typeparam>
    public interface IEFCoreApplicationService<TEntityDto, TKey, in TGetAllInput, in TCreateInputDto> : IEFCoreApplicationService<TEntityDto, TKey, TGetAllInput, TCreateInputDto, TCreateInputDto>
        where TEntityDto : class, IEntityDto<TKey>
        where TCreateInputDto : class, IEntityDto<TKey>
    {
    }

    /// <summary>
    /// 方法包括：CURD、获取全部、分页获取 
    /// </summary>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TGetAllInput"></typeparam>
    /// <typeparam name="TCreateInputDto"></typeparam>
    /// <typeparam name="TUpdateInputDto"></typeparam>
    public interface IEFCoreApplicationService<TEntityDto, TKey, in TGetAllInput, in TCreateInputDto, in TUpdateInputDto> : IMSApplicationService<TEntityDto, TKey, TGetAllInput, TCreateInputDto, TUpdateInputDto, MasterDbContextLocator, SlaveDbContextLocator>
        where TEntityDto : class, IEntityDto<TKey>
        where TCreateInputDto : class, IEntityDto<TKey>
        where TUpdateInputDto : class, IEntityDto<TKey>
    {
    }

    /// <summary>
    /// 方法包括：CURD、获取全部、分页获取 
    /// </summary>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TGetAllInput"></typeparam>
    /// <typeparam name="TMasterDbContextLocator"></typeparam>
    /// <typeparam name="TSlaveDbContextLocator"></typeparam>
    public interface IMSApplicationService<TEntityDto, TKey, in TGetAllInput, TMasterDbContextLocator, TSlaveDbContextLocator> :
        IMSApplicationService<TEntityDto, TKey, TGetAllInput, TEntityDto, TMasterDbContextLocator, TSlaveDbContextLocator>
       where TEntityDto : class, IEntityDto<TKey>
       where TMasterDbContextLocator : class, IDbContextLocator
       where TSlaveDbContextLocator : class, IDbContextLocator
    {
    }

    /// <summary>
    /// 方法包括：CURD、获取全部、分页获取 
    /// </summary>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TGetAllInput"></typeparam>
    /// <typeparam name="TCreateInputDto"></typeparam>
    /// <typeparam name="TMasterDbContextLocator"></typeparam>
    /// <typeparam name="TSlaveDbContextLocator"></typeparam>
    public interface IMSApplicationService<TEntityDto, TKey, in TGetAllInput, in TCreateInputDto, TMasterDbContextLocator, TSlaveDbContextLocator> :
        IMSApplicationService<TEntityDto, TKey, TGetAllInput, TCreateInputDto, TCreateInputDto, TMasterDbContextLocator, TSlaveDbContextLocator>
       where TEntityDto : class, IEntityDto<TKey>
       where TCreateInputDto : class, IEntityDto<TKey>
       where TMasterDbContextLocator : class, IDbContextLocator
       where TSlaveDbContextLocator : class, IDbContextLocator
    {
    }

    /// <summary>
    /// 方法包括：CURD、获取全部、分页获取 
    /// </summary>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TGetAllInput"></typeparam>
    /// <typeparam name="TCreateInputDto"></typeparam>
    /// <typeparam name="TUpdateInputDto"></typeparam>
    /// <typeparam name="TMasterDbContextLocator"></typeparam>
    /// <typeparam name="TSlaveDbContextLocator"></typeparam>
    public interface IMSApplicationService<TEntityDto, TKey, in TGetAllInput, in TCreateInputDto, in TUpdateInputDto, TMasterDbContextLocator, TSlaveDbContextLocator> : IApplicationService<TEntityDto, TKey, TGetAllInput, TCreateInputDto, TUpdateInputDto>
    where TEntityDto : class, IEntityDto<TKey>
    where TCreateInputDto : class, IEntityDto<TKey>
    where TUpdateInputDto : class, IEntityDto<TKey>
    where TMasterDbContextLocator : class, IDbContextLocator
    where TSlaveDbContextLocator : class, IDbContextLocator
    {
        /// <summary>
        /// 根据id查询一条数据缓存
        /// </summary>
        /// <param name="id"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<TEntityDto> GetCacheById(TKey id, CancellationToken cancellationToken = default);
    }
}